home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4500 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.6 KB

  1. Path: nntp-xfer-2.csn.net!yuma!steffend
  2. From: steffend@lamar.colostate.edu (Dave Steffen)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Help!! I'm a stuck newbie - input problem
  5. Date: 30 Jan 1996 17:34:23 GMT
  6. Organization: Colorado State University, Fort Collins, CO  80523
  7. Distribution: world
  8. Message-ID: <4elkqv$3f2q@yuma.ACNS.ColoState.EDU>
  9. References: <4eh3vl$g8i@atlas.uniserve.com> <4eipbe$jnd@nic.cc.ruu.nl> <4ek25k$qta@atlas.uniserve.com>
  10. NNTP-Posting-Host: glitch.physics.colostate.edu
  11. X-Newsreader: TIN [version 1.2 PL2]
  12.  
  13. Chris (nowher@anyplace.com) wrote:
  14.  
  15. > I have tried the strncpy function and it limits the length of the input. 
  16. > I also tried cin.width which also nicely limited the length of the input 
  17. > string.  My exact problem is that I don't wan't the cursor to over-run 
  18. > the width of the field:
  19.  
  20. > Part Number:(            )
  21. >      Length:(    )
  22. >       Width:(    )
  23. >     .
  24. >     .
  25. >     .
  26.  
  27.  
  28.     Ah... "This different question, grasshopper." The problem is
  29. then, "How do I get control of the cursor?"
  30.  
  31.     Two answers, one of them platform-dependent. If you're working
  32. with Borland on a PC, check out their "constrea.h" library - it's got
  33. exactly what you're looking for. If you're not on a PC, there may be a
  34. library you can use for screen control (Xwindows or something)?
  35.  
  36.     Otherwise, you may have to write your own input
  37. routine. Depending on what you do, this may or may not be platform
  38. specific.
  39.  
  40. > The bracket on the right should be the limit of the input.  I would like 
  41. > to beep the user when/if the user reaches the right side of the field.
  42. > I have tried the getch() function in conjunction with wherex(), but this 
  43. > failed. Perhaps I am asking the wrong question. What is the easiest way 
  44. > of dealing with an array of char?
  45.  
  46. > Actually, when I use   char PartNum[20];  I have trouble assigning a 
  47. > value to it. I get the error --Lvalue required--.
  48.  
  49.     Well, you can't assign to "PartNum" because that's a pointer
  50. to some chunk of memory, right? You can't assign to a memory
  51. address. What you want to do is assign to _what PartNum points to_,
  52. i.e. PartNum[0], PartNum[1]... Alternately, use strcpy to do it.
  53.  
  54.                                  /\
  55.                                  \/
  56.  
  57. Dave Steffen                      No, his mind is not for rent
  58. Dept. of Physics                  To any God or Government
  59. Colorado State University         Always hopeful, yet discontent
  60. steffend@lamar.colostate edu      He knows changes aren't permanent-
  61.                       But change is...
  62. "Speak softly...                    
  63. ... and carry a black belt!"              -Neal Peart / RUSH
  64. -----------------------------------------------------------------------
  65.